package com.erms.lab.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.erms.common.annotation.Log;
import com.erms.common.enums.BusinessType;
import com.erms.lab.domain.LabMajorFive;
import com.erms.lab.service.ILabMajorFiveService;
import com.erms.common.core.controller.BaseController;
import com.erms.common.core.domain.AjaxResult;
import com.erms.common.utils.poi.ExcelUtil;
import com.erms.common.core.page.TableDataInfo;

/**
 * 专业机房五Controller
 * 
 * @author smile
 * @date 2020-05-04
 */
@Controller
@RequestMapping("/lab/major_five")
public class LabMajorFiveController extends BaseController
{
    private String prefix = "lab/major_five";

    @Autowired
    private ILabMajorFiveService labMajorFiveService;

    @RequiresPermissions("lab:major_five:view")
    @GetMapping()
    public String major_five()
    {
        return prefix + "/major_five";
    }

    /**
     * 查询专业机房五列表
     */
    @RequiresPermissions("lab:major_five:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(LabMajorFive labMajorFive)
    {
        startPage();
        List<LabMajorFive> list = labMajorFiveService.selectLabMajorFiveList(labMajorFive);
        return getDataTable(list);
    }

    /**
     * 导出专业机房五列表
     */
    @RequiresPermissions("lab:major_five:export")
    @Log(title = "专业机房五", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(LabMajorFive labMajorFive)
    {
        List<LabMajorFive> list = labMajorFiveService.selectLabMajorFiveList(labMajorFive);
        ExcelUtil<LabMajorFive> util = new ExcelUtil<LabMajorFive>(LabMajorFive.class);
        return util.exportExcel(list, "major_five");
    }

    /**
     * 新增专业机房五
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存专业机房五
     */
    @RequiresPermissions("lab:major_five:add")
    @Log(title = "专业机房五", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(LabMajorFive labMajorFive)
    {
        return toAjax(labMajorFiveService.insertLabMajorFive(labMajorFive));
    }

    /**
     * 修改专业机房五
     */
    @GetMapping("/edit/{equipId}")
    public String edit(@PathVariable("equipId") Long equipId, ModelMap mmap)
    {
        LabMajorFive labMajorFive = labMajorFiveService.selectLabMajorFiveById(equipId);
        mmap.put("labMajorFive", labMajorFive);
        return prefix + "/edit";
    }

    /**
     * 修改保存专业机房五
     */
    @RequiresPermissions("lab:major_five:edit")
    @Log(title = "专业机房五", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(LabMajorFive labMajorFive)
    {
        return toAjax(labMajorFiveService.updateLabMajorFive(labMajorFive));
    }

    /**
     * 删除专业机房五
     */
    @RequiresPermissions("lab:major_five:remove")
    @Log(title = "专业机房五", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(labMajorFiveService.deleteLabMajorFiveByIds(ids));
    }
}
